//
//  HMNetWorkTool.m
//  NewsBoard
//
//  Created by heima on 16/3/27.
//  Copyright © 2016年 heima. All rights reserved.
//

#import "VIZNetWorkTool.h"

@implementation VIZNetWorkTool


static NSString * const BaseURLString = @"http://c.m.163.com/nc/";

static VIZNetWorkTool *_instance;

+ (instancetype)sharedHMNetWorkTool{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        _instance = [[self alloc] initWithBaseURL:[NSURL URLWithString:BaseURLString]];
        
        //TODO
        _instance.responseSerializer.acceptableContentTypes = [_instance.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
    });
    
    return _instance;
}

- (void)getWithURLString:(NSString *)URLString finishedBlock:(FinishedBlock)finishedBlock{
    //self就是单例
    [self GET:URLString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (finishedBlock) {
            //返回给模型
            finishedBlock(responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
    
    //ASI
}

@end
